﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SheepStorage.API.Application.Command.BodySizeCommand;
using SheepStorage.API.Application.Command.SheepMomDeliveryCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Controllers
{
    /// <summary>
    /// 种母分娩
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SheepMomDeliveryController : ControllerBase
    {
        private readonly IMediator _mediator;
        private readonly ISheepMomDeliveryService mediatorService;
        public SheepMomDeliveryController(IMediator mediator, ISheepMomDeliveryService mediatorService)
        {
            _mediator = mediator;
            this.mediatorService = mediatorService;
        }
        /// <summary>
        /// 种母分娩显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<List<SheepMomDeliveryDto>>> GetSheepMomDelivery(SheepMomDeliveryShowCommand request)
        {
            return await _mediator.Send(request);
        }
        /// <summary>
        /// 种母分娩添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]

        public async Task<Results<int>> AddSheepMomDelivery(SheepMomDeliveryAddCommand request)
        {
            return await _mediator.Send(request);
        }
        /// <summary>
        /// 种母分娩信息删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> DelSheepMomDelivery(SheepMomDeliveryDelCommand request)
        {
            return await _mediator.Send(request);
        }
        /// <summary>
        /// 种母分娩信息反填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<SheepMomDelivery>> BackFillSheepMomDelivery(SheepMomDeliveryBackfillCommand request)
        {
            return await _mediator.Send(request);
        }
        /// <summary>
        /// 种母分娩信息修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> Handle(SheepMomDeliveryUpdateCommand request)
        {
            return await _mediator.Send(request);
        }
        /// <summary>
        /// 种母分娩显示 图表显示
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetSheepMomDeliveryList()
        {
            var list= mediatorService.GetSheepMomDeliveryList();
            return Ok(list);    
        }

    }
}
